
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Ezio.Model;

//Service Route: Copy to 'Global.asax'
//  RouteTable.Routes.Add(new ServiceRoute("Compromisos", new WebServiceHostFactory(), typeof(CompromisosService)));
//
namespace Ezio.Service
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [XmlSerializerFormat]
    public class CompromisosService : BaseService
    {

        [WebInvoke(UriTemplate = "", Method = "POST")]
        public bool Create(Compromisos Compromio)
        {
            Provider.AddToCompromisos(Compromio);
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "{Id}", Method = "GET")]
        public Compromisos GetById(string Id)
        {
            return Provider.Compromisos.First(i => i.IdCompromiso == int.Parse(Id));
        }

        [WebInvoke(UriTemplate = "", Method = "PUT")]
        public bool Update(Compromisos Compromiso)
        {
            Compromisos miCompromio = Provider.Compromisos.Where(t => t.IdCompromiso == Compromiso.IdCompromiso).First();
            miCompromio.Copy(Compromiso);
            return Provider.TrySaveChanges();
        }

    }
}